package cj.web.tb.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.tb.domain.TBArea;

/**
 * 
 * @author 
 *
 */
@DAO
public interface TBAreaDAO{
	
	@SQL("SELECT * FROM TBArea WHERE deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } ORDER BY id DESC LIMIT :t.start,:t.length ")
    List<TBArea> query(@SQLParam("t") TBArea tBArea);
	
	@SQL("SELECT name FROM TBArea WHERE deleteFlag=1 ORDER BY id ")
    List<String> queryAreaNameAll();
	
	@SQL("SELECT count(1) FROM TBArea WHERE deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } ")
    int querySize(@SQLParam("t") TBArea tBArea);
    
    @SQL("SELECT * FROM TBArea WHERE id=:1")
    TBArea queryById(int id);
    
    @SQL("INSERT INTO TBArea (name,deleteFlag,createAt,createUser,updateAt,updateUser) VALUES (:t.name,1,now(),:t.createUser,now(),:t.updateUser)")
    void create(@SQLParam("t") TBArea tBArea);
	
	@SQL("UPDATE TBArea SET name=:t.name,updateAt=now(),updateUser=:t.updateUser WHERE id=:t.id")
    void update(@SQLParam("t") TBArea tBArea);
    
    @SQL("UPDATE TBArea SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}